/*
 * Allwinner SoCs display driver.
 *
 * Copyright (C) 2016 Allwinner.
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2.  This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */

#include "ili9881c.h"
#include "panels.h"

extern s32 bsp_disp_get_panel_info(u32 screen_id,
		struct disp_panel_para *info);
static void LCD_power_on(u32 sel);
static void LCD_power_off(u32 sel);
static void LCD_bl_open(u32 sel);
static void LCD_bl_close(u32 sel);

static void LCD_panel_init(u32 sel);
static void LCD_panel_exit(u32 sel);

#define panel_reset(sel, val) sunxi_lcd_gpio_set_value(sel, 1, val)
#define power_en(sel, val) sunxi_lcd_gpio_set_value(sel, 0, val)

static void LCD_cfg_panel_info(struct panel_extend_para *info)
{
	u32 i = 0, j = 0;
	u32 items;
	u8 lcd_gamma_tbl[][2] = {
		/*{input value, corrected value} */
		{0, 0}, {15, 15}, {30, 30}, {45, 45}, {60, 60},
		{75, 75}, {90, 90}, {105, 105}, {120, 120}, {135, 135},
		{150, 150}, {165, 165}, {180, 180}, {195, 195}, {210, 210},
		{225, 225}, {240, 240}, {255, 255},
	};

	u32 lcd_cmap_tbl[2][3][4] = {
	{
		{LCD_CMAP_G0, LCD_CMAP_B1, LCD_CMAP_G2, LCD_CMAP_B3},
		{LCD_CMAP_B0, LCD_CMAP_R1, LCD_CMAP_B2, LCD_CMAP_R3},
		{LCD_CMAP_R0, LCD_CMAP_G1, LCD_CMAP_R2, LCD_CMAP_G3},
	},
	{
		{LCD_CMAP_B3, LCD_CMAP_G2, LCD_CMAP_B1, LCD_CMAP_G0},
		{LCD_CMAP_R3, LCD_CMAP_B2, LCD_CMAP_R1, LCD_CMAP_B0},
		{LCD_CMAP_G3, LCD_CMAP_R2, LCD_CMAP_G1, LCD_CMAP_R0},
	    },
	};

	items = sizeof(lcd_gamma_tbl) / 2;
	for (i = 0; i < items - 1; i++) {
		u32 num = lcd_gamma_tbl[i + 1][0] - lcd_gamma_tbl[i][0];

		for (j = 0; j < num; j++) {
			u32 value = 0;

			value =
			lcd_gamma_tbl[i][1] +
			((lcd_gamma_tbl[i + 1][1] - lcd_gamma_tbl[i][1]) *
			j) /
				num;
			info->lcd_gamma_tbl[lcd_gamma_tbl[i][0] + j] =
			(value << 16) + (value << 8) + value;
		}
	}
	info->lcd_gamma_tbl[255] = (lcd_gamma_tbl[items - 1][1] << 16) +
				(lcd_gamma_tbl[items - 1][1] << 8) +
				lcd_gamma_tbl[items - 1][1];

	memcpy(info->lcd_cmap_tbl, lcd_cmap_tbl, sizeof(lcd_cmap_tbl));
}

static s32 LCD_open_flow(u32 sel)
{
	LCD_OPEN_FUNC(sel, LCD_power_on,
		100); /* open lcd power, and delay 50ms */
	LCD_OPEN_FUNC(sel, LCD_panel_init,
		200); /* open lcd power, than delay 200ms */
	LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable,
		50); /* open lcd controller, and delay 100ms */
	LCD_OPEN_FUNC(sel, LCD_bl_open,
		0); /* open lcd backlight, and delay 0ms */

	return 0;
}

static s32 LCD_close_flow(u32 sel)
{
	LCD_CLOSE_FUNC(sel, LCD_bl_close,
		200); /* close lcd backlight, and delay 0ms */
	LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable,
		20); /* close lcd controller, and delay 0ms */
	LCD_CLOSE_FUNC(sel, LCD_panel_exit,
		10); /* open lcd power, than delay 200ms */
	LCD_CLOSE_FUNC(sel, LCD_power_off,
		500); /* close lcd power, and delay 500ms */

	return 0;
}

static void LCD_power_on(u32 sel)
{
	sunxi_lcd_pin_cfg(sel, 1);
	sunxi_lcd_power_enable(sel, 0);
	sunxi_lcd_delay_ms(5);
	sunxi_lcd_power_enable(sel, 1);
	sunxi_lcd_delay_ms(5);
	sunxi_lcd_power_enable(sel, 2);
	sunxi_lcd_delay_ms(5);
	power_en(sel, 1);
	sunxi_lcd_delay_ms(20);
	panel_reset(sel, 0);
	sunxi_lcd_delay_ms(10);
	panel_reset(sel, 1);
}

static void LCD_power_off(u32 sel)
{
	sunxi_lcd_pin_cfg(sel, 0);
	power_en(sel, 0);
	sunxi_lcd_delay_ms(20);
	panel_reset(sel, 0);
	sunxi_lcd_delay_ms(5);
	sunxi_lcd_power_disable(
	sel, 2); /* lcd power2 */
	sunxi_lcd_delay_ms(5);
	sunxi_lcd_power_disable(
	sel, 1); /* lcd power1 */
	sunxi_lcd_delay_ms(5);
	sunxi_lcd_power_disable(
	sel, 0); /* lcd power */
}

static void LCD_bl_open(u32 sel)
{
	sunxi_lcd_pwm_enable(sel);
	sunxi_lcd_delay_ms(50);
	sunxi_lcd_backlight_enable(sel);
}

static void LCD_bl_close(u32 sel)
{
	sunxi_lcd_backlight_disable(sel);
	sunxi_lcd_delay_ms(20);
	sunxi_lcd_pwm_disable(sel);
}

#define REGFLAG_DELAY 0XFE
#define REGFLAG_END_OF_TABLE 0xFF

struct LCM_setting_table {
	u8 cmd;
	u32 count;
	u8 para_list[64];
};

enum ili9881c_op {
	ILI9881C_SWITCH_PAGE,
	ILI9881C_COMMAND,
};

struct ili9881c_instr {
	enum ili9881c_op op;

	union arg {
		struct cmd {
			u8	cmd;
			u8	data;
		} cmd;
		u8	page;
	} arg;
};

#define ILI9881C_SWITCH_PAGE_INSTR(_page)	\
	{					\
		.op = ILI9881C_SWITCH_PAGE,	\
		.arg = {			\
			.page = (_page),	\
		},				\
	}

#define ILI9881C_COMMAND_INSTR(_cmd, _data)		\
	{						\
		.op = ILI9881C_COMMAND,		\
		.arg = {				\
			.cmd = {			\
				.cmd = (_cmd),		\
				.data = (_data),	\
			},				\
		},					\
	}

static struct ili9881c_instr ili9881c_init[] = {
ILI9881C_SWITCH_PAGE_INSTR(3),
ILI9881C_COMMAND_INSTR(0x01, 0x00),
ILI9881C_COMMAND_INSTR(0x02, 0x00),
ILI9881C_COMMAND_INSTR(0x03, 0x56),
ILI9881C_COMMAND_INSTR(0x04, 0x13),
ILI9881C_COMMAND_INSTR(0x05, 0x00),
ILI9881C_COMMAND_INSTR(0x06, 0x06),
ILI9881C_COMMAND_INSTR(0x07, 0x01),
ILI9881C_COMMAND_INSTR(0x08, 0x00),
ILI9881C_COMMAND_INSTR(0x09, 0x30),
ILI9881C_COMMAND_INSTR(0x0A, 0x01),
ILI9881C_COMMAND_INSTR(0x0B, 0x00),
ILI9881C_COMMAND_INSTR(0x0C, 0x30),
ILI9881C_COMMAND_INSTR(0x0D, 0x01),
ILI9881C_COMMAND_INSTR(0x0E, 0x00),
ILI9881C_COMMAND_INSTR(0x0F, 0x18),
ILI9881C_COMMAND_INSTR(0x10, 0x18),
ILI9881C_COMMAND_INSTR(0x11, 0x00),
ILI9881C_COMMAND_INSTR(0x12, 0x00),
ILI9881C_COMMAND_INSTR(0x13, 0x00),
ILI9881C_COMMAND_INSTR(0x14, 0x00),
ILI9881C_COMMAND_INSTR(0x15, 0x00),
ILI9881C_COMMAND_INSTR(0x16, 0x00),
ILI9881C_COMMAND_INSTR(0x17, 0x00),
ILI9881C_COMMAND_INSTR(0x18, 0x00),
ILI9881C_COMMAND_INSTR(0x19, 0x00),
ILI9881C_COMMAND_INSTR(0x1A, 0x00),
ILI9881C_COMMAND_INSTR(0x1B, 0x00),
ILI9881C_COMMAND_INSTR(0x1C, 0x00),
ILI9881C_COMMAND_INSTR(0x1D, 0x00),
ILI9881C_COMMAND_INSTR(0x1E, 0x40),
ILI9881C_COMMAND_INSTR(0x1F, 0xC0),
ILI9881C_COMMAND_INSTR(0x20, 0x02),
ILI9881C_COMMAND_INSTR(0x21, 0x05),
ILI9881C_COMMAND_INSTR(0x22, 0x02),
ILI9881C_COMMAND_INSTR(0x23, 0x00),
ILI9881C_COMMAND_INSTR(0x24, 0x86),
ILI9881C_COMMAND_INSTR(0x25, 0x85),
ILI9881C_COMMAND_INSTR(0x26, 0x00),
ILI9881C_COMMAND_INSTR(0x27, 0x00),
ILI9881C_COMMAND_INSTR(0x28, 0x3B),
ILI9881C_COMMAND_INSTR(0x29, 0x03),
ILI9881C_COMMAND_INSTR(0x2A, 0x00),
ILI9881C_COMMAND_INSTR(0x2B, 0x00),
ILI9881C_COMMAND_INSTR(0x2C, 0x00),
ILI9881C_COMMAND_INSTR(0x2D, 0x00),
ILI9881C_COMMAND_INSTR(0x2E, 0x00),
ILI9881C_COMMAND_INSTR(0x2F, 0x00),
ILI9881C_COMMAND_INSTR(0x30, 0x00),
ILI9881C_COMMAND_INSTR(0x31, 0x00),
ILI9881C_COMMAND_INSTR(0x32, 0x00),
ILI9881C_COMMAND_INSTR(0x33, 0x00),
ILI9881C_COMMAND_INSTR(0x34, 0x00),
ILI9881C_COMMAND_INSTR(0x35, 0x00),
ILI9881C_COMMAND_INSTR(0x36, 0x00),
ILI9881C_COMMAND_INSTR(0x37, 0x00),
ILI9881C_COMMAND_INSTR(0x38, 0x00),
ILI9881C_COMMAND_INSTR(0x39, 0x00),
ILI9881C_COMMAND_INSTR(0x3A, 0x00),
ILI9881C_COMMAND_INSTR(0x3B, 0x00),
ILI9881C_COMMAND_INSTR(0x3C, 0x00),
ILI9881C_COMMAND_INSTR(0x3D, 0x00),
ILI9881C_COMMAND_INSTR(0x3E, 0x00),
ILI9881C_COMMAND_INSTR(0x3F, 0x00),
ILI9881C_COMMAND_INSTR(0x40, 0x00),
ILI9881C_COMMAND_INSTR(0x41, 0x00),
ILI9881C_COMMAND_INSTR(0x42, 0x00),
ILI9881C_COMMAND_INSTR(0x43, 0x00),
ILI9881C_COMMAND_INSTR(0x44, 0x00),
ILI9881C_COMMAND_INSTR(0x50, 0x01),
ILI9881C_COMMAND_INSTR(0x51, 0x23),
ILI9881C_COMMAND_INSTR(0x52, 0x45),
ILI9881C_COMMAND_INSTR(0x53, 0x67),
ILI9881C_COMMAND_INSTR(0x54, 0x89),
ILI9881C_COMMAND_INSTR(0x55, 0xAB),
ILI9881C_COMMAND_INSTR(0x56, 0x01),
ILI9881C_COMMAND_INSTR(0x57, 0x23),
ILI9881C_COMMAND_INSTR(0x58, 0x45),
ILI9881C_COMMAND_INSTR(0x59, 0x67),
ILI9881C_COMMAND_INSTR(0x5A, 0x89),
ILI9881C_COMMAND_INSTR(0x5B, 0xAB),
ILI9881C_COMMAND_INSTR(0x5C, 0xCD),
ILI9881C_COMMAND_INSTR(0x5D, 0xEF),
ILI9881C_COMMAND_INSTR(0x5E, 0x11),
ILI9881C_COMMAND_INSTR(0x5F, 0x08),
ILI9881C_COMMAND_INSTR(0x60, 0x00),
ILI9881C_COMMAND_INSTR(0x61, 0x01),
ILI9881C_COMMAND_INSTR(0x62, 0x02),
ILI9881C_COMMAND_INSTR(0x63, 0x02),
ILI9881C_COMMAND_INSTR(0x64, 0x0F),
ILI9881C_COMMAND_INSTR(0x65, 0x0E),
ILI9881C_COMMAND_INSTR(0x66, 0x0D),
ILI9881C_COMMAND_INSTR(0x67, 0x0C),
ILI9881C_COMMAND_INSTR(0x68, 0x02),
ILI9881C_COMMAND_INSTR(0x69, 0x02),
ILI9881C_COMMAND_INSTR(0x6A, 0x02),
ILI9881C_COMMAND_INSTR(0x6B, 0x02),
ILI9881C_COMMAND_INSTR(0x6C, 0x02),
ILI9881C_COMMAND_INSTR(0x6D, 0x02),
ILI9881C_COMMAND_INSTR(0x6E, 0x06),
ILI9881C_COMMAND_INSTR(0x6F, 0x02),
ILI9881C_COMMAND_INSTR(0x70, 0x02),
ILI9881C_COMMAND_INSTR(0x71, 0x02),
ILI9881C_COMMAND_INSTR(0x72, 0x02),
ILI9881C_COMMAND_INSTR(0x73, 0x02),
ILI9881C_COMMAND_INSTR(0x74, 0x02),
ILI9881C_COMMAND_INSTR(0x75, 0x06),
ILI9881C_COMMAND_INSTR(0x76, 0x00),
ILI9881C_COMMAND_INSTR(0x77, 0x01),
ILI9881C_COMMAND_INSTR(0x78, 0x02),
ILI9881C_COMMAND_INSTR(0x79, 0x02),
ILI9881C_COMMAND_INSTR(0x7A, 0x0F),
ILI9881C_COMMAND_INSTR(0x7B, 0x0E),
ILI9881C_COMMAND_INSTR(0x7C, 0x0D),
ILI9881C_COMMAND_INSTR(0x7D, 0x0C),
ILI9881C_COMMAND_INSTR(0x7E, 0x02),
ILI9881C_COMMAND_INSTR(0x7F, 0x02),
ILI9881C_COMMAND_INSTR(0x80, 0x02),
ILI9881C_COMMAND_INSTR(0x81, 0x02),
ILI9881C_COMMAND_INSTR(0x82, 0x02),
ILI9881C_COMMAND_INSTR(0x83, 0x02),
ILI9881C_COMMAND_INSTR(0x84, 0x08),
ILI9881C_COMMAND_INSTR(0x85, 0x02),
ILI9881C_COMMAND_INSTR(0x86, 0x02),
ILI9881C_COMMAND_INSTR(0x87, 0x02),
ILI9881C_COMMAND_INSTR(0x88, 0x02),
ILI9881C_COMMAND_INSTR(0x89, 0x02),
ILI9881C_COMMAND_INSTR(0x8A, 0x02),
ILI9881C_SWITCH_PAGE_INSTR(4),
ILI9881C_COMMAND_INSTR(0x6C, 0x15),
ILI9881C_COMMAND_INSTR(0x6E, 0x2B),
ILI9881C_COMMAND_INSTR(0x6F, 0x33),
ILI9881C_COMMAND_INSTR(0x8D, 0x15),
ILI9881C_COMMAND_INSTR(0x87, 0xBA),
ILI9881C_COMMAND_INSTR(0x26, 0x76),
ILI9881C_COMMAND_INSTR(0xB2, 0xD1),
ILI9881C_COMMAND_INSTR(0xB5, 0x07),
ILI9881C_COMMAND_INSTR(0x35, 0x1F),
ILI9881C_COMMAND_INSTR(0x3A, 0x24),
ILI9881C_SWITCH_PAGE_INSTR(1),
ILI9881C_COMMAND_INSTR(0x22, 0x0A),
ILI9881C_COMMAND_INSTR(0x31, 0x00),
ILI9881C_COMMAND_INSTR(0x50, 0xB7),
ILI9881C_COMMAND_INSTR(0x51, 0xB7),
ILI9881C_COMMAND_INSTR(0x60, 0x30),
ILI9881C_COMMAND_INSTR(0x61, 0x00),
ILI9881C_COMMAND_INSTR(0x62, 0x19),
ILI9881C_COMMAND_INSTR(0x63, 0x10),
ILI9881C_SWITCH_PAGE_INSTR(5),
ILI9881C_COMMAND_INSTR(0x80, 0x01),
ILI9881C_SWITCH_PAGE_INSTR(1),
ILI9881C_COMMAND_INSTR(0x34, 0x01),
ILI9881C_COMMAND_INSTR(0xA0, 0x18),
ILI9881C_COMMAND_INSTR(0xA1, 0x2A),
ILI9881C_COMMAND_INSTR(0xA2, 0x39),
ILI9881C_COMMAND_INSTR(0xA3, 0x14),
ILI9881C_COMMAND_INSTR(0xA4, 0x17),
ILI9881C_COMMAND_INSTR(0xA5, 0x2A),
ILI9881C_COMMAND_INSTR(0xA6, 0x1D),
ILI9881C_COMMAND_INSTR(0xA7, 0x1E),
ILI9881C_COMMAND_INSTR(0xA8, 0xA5),
ILI9881C_COMMAND_INSTR(0xA9, 0x1C),
ILI9881C_COMMAND_INSTR(0xAA, 0x28),
ILI9881C_COMMAND_INSTR(0xAB, 0x99),
ILI9881C_COMMAND_INSTR(0xAC, 0x1C),
ILI9881C_COMMAND_INSTR(0xAD, 0x1C),
ILI9881C_COMMAND_INSTR(0xAE, 0x4F),
ILI9881C_COMMAND_INSTR(0xAF, 0x23),
ILI9881C_COMMAND_INSTR(0xB0, 0x28),
ILI9881C_COMMAND_INSTR(0xB1, 0x5E),
ILI9881C_COMMAND_INSTR(0xB2, 0x6D),
ILI9881C_COMMAND_INSTR(0xB3, 0x39),
ILI9881C_COMMAND_INSTR(0xC0, 0x16),
ILI9881C_COMMAND_INSTR(0xC1, 0x29),
ILI9881C_COMMAND_INSTR(0xC2, 0x38),
ILI9881C_COMMAND_INSTR(0xC3, 0x15),
ILI9881C_COMMAND_INSTR(0xC4, 0x18),
ILI9881C_COMMAND_INSTR(0xC5, 0x2C),
ILI9881C_COMMAND_INSTR(0xC6, 0x20),
ILI9881C_COMMAND_INSTR(0xC7, 0x20),
ILI9881C_COMMAND_INSTR(0xC8, 0xAE),
ILI9881C_COMMAND_INSTR(0xC9, 0x1C),
ILI9881C_COMMAND_INSTR(0xCA, 0x28),
ILI9881C_COMMAND_INSTR(0xCB, 0x99),
ILI9881C_COMMAND_INSTR(0xCC, 0x1D),
ILI9881C_COMMAND_INSTR(0xCD, 0x1B),
ILI9881C_COMMAND_INSTR(0xCE, 0x50),
ILI9881C_COMMAND_INSTR(0xCF, 0x24),
ILI9881C_COMMAND_INSTR(0xD0, 0x29),
ILI9881C_COMMAND_INSTR(0xD1, 0x5D),
ILI9881C_COMMAND_INSTR(0xD2, 0x6C),
ILI9881C_COMMAND_INSTR(0xD3, 0x39),
ILI9881C_SWITCH_PAGE_INSTR(5),
ILI9881C_COMMAND_INSTR(0x00, 0x00),
ILI9881C_COMMAND_INSTR(0x01, 0x00),
ILI9881C_COMMAND_INSTR(0x02, 0x00),
ILI9881C_COMMAND_INSTR(0x03, 0x00),
ILI9881C_COMMAND_INSTR(0x04, 0x00),
ILI9881C_COMMAND_INSTR(0x05, 0x00),
ILI9881C_COMMAND_INSTR(0x06, 0x00),
ILI9881C_COMMAND_INSTR(0x07, 0x00),
ILI9881C_COMMAND_INSTR(0x08, 0x00),
ILI9881C_COMMAND_INSTR(0x09, 0x00),
ILI9881C_COMMAND_INSTR(0x0A, 0x00),
ILI9881C_COMMAND_INSTR(0x0B, 0x00),
ILI9881C_COMMAND_INSTR(0x0C, 0x00),
ILI9881C_COMMAND_INSTR(0x0D, 0x00),
ILI9881C_COMMAND_INSTR(0x0E, 0x00),
ILI9881C_COMMAND_INSTR(0x0F, 0x00),
ILI9881C_COMMAND_INSTR(0x10, 0x00),
ILI9881C_COMMAND_INSTR(0x11, 0x00),
ILI9881C_COMMAND_INSTR(0x12, 0x00),
ILI9881C_COMMAND_INSTR(0x13, 0x00),
ILI9881C_COMMAND_INSTR(0x14, 0x00),
ILI9881C_COMMAND_INSTR(0x15, 0x00),
ILI9881C_COMMAND_INSTR(0x16, 0x81),
ILI9881C_COMMAND_INSTR(0x17, 0x81),
ILI9881C_COMMAND_INSTR(0x18, 0x81),
ILI9881C_COMMAND_INSTR(0x19, 0x81),
ILI9881C_COMMAND_INSTR(0x1A, 0x81),
ILI9881C_COMMAND_INSTR(0x1B, 0x81),
ILI9881C_COMMAND_INSTR(0x1C, 0x81),
ILI9881C_COMMAND_INSTR(0x1D, 0x81),
ILI9881C_COMMAND_INSTR(0x1E, 0x81),
ILI9881C_COMMAND_INSTR(0x1F, 0x81),
ILI9881C_COMMAND_INSTR(0x20, 0x81),
ILI9881C_COMMAND_INSTR(0x21, 0x81),
ILI9881C_COMMAND_INSTR(0x22, 0x81),
ILI9881C_COMMAND_INSTR(0x23, 0x81),
ILI9881C_COMMAND_INSTR(0x24, 0x81),
ILI9881C_COMMAND_INSTR(0x25, 0x81),
ILI9881C_COMMAND_INSTR(0x26, 0x81),
ILI9881C_COMMAND_INSTR(0x27, 0x81),
ILI9881C_COMMAND_INSTR(0x28, 0x81),
ILI9881C_COMMAND_INSTR(0x29, 0x81),
ILI9881C_COMMAND_INSTR(0x2A, 0x81),
ILI9881C_COMMAND_INSTR(0x2B, 0x81),
ILI9881C_COMMAND_INSTR(0x2C, 0x81),
ILI9881C_COMMAND_INSTR(0x2D, 0x81),
ILI9881C_COMMAND_INSTR(0x2E, 0x81),
ILI9881C_COMMAND_INSTR(0x2F, 0x81),
ILI9881C_COMMAND_INSTR(0x30, 0x81),
ILI9881C_COMMAND_INSTR(0x31, 0x81),
ILI9881C_COMMAND_INSTR(0x32, 0x81),
ILI9881C_COMMAND_INSTR(0x33, 0x81),
ILI9881C_COMMAND_INSTR(0x34, 0x81),
ILI9881C_COMMAND_INSTR(0x35, 0x81),
ILI9881C_COMMAND_INSTR(0x36, 0x81),
ILI9881C_COMMAND_INSTR(0x37, 0x81),
ILI9881C_COMMAND_INSTR(0x38, 0x81),
ILI9881C_COMMAND_INSTR(0x39, 0x81),
ILI9881C_COMMAND_INSTR(0x3A, 0x81),
ILI9881C_COMMAND_INSTR(0x3B, 0x81),
ILI9881C_COMMAND_INSTR(0x3C, 0x81),
ILI9881C_COMMAND_INSTR(0x3D, 0x81),
ILI9881C_COMMAND_INSTR(0x3E, 0x81),
ILI9881C_COMMAND_INSTR(0x3F, 0x81),
ILI9881C_COMMAND_INSTR(0x40, 0x81),
ILI9881C_COMMAND_INSTR(0x41, 0x82),
ILI9881C_COMMAND_INSTR(0x42, 0x82),
ILI9881C_COMMAND_INSTR(0x43, 0x82),
ILI9881C_COMMAND_INSTR(0x44, 0x82),
ILI9881C_COMMAND_INSTR(0x45, 0x82),
ILI9881C_COMMAND_INSTR(0x46, 0x82),
ILI9881C_COMMAND_INSTR(0x47, 0x82),
ILI9881C_COMMAND_INSTR(0x48, 0x82),
ILI9881C_COMMAND_INSTR(0x49, 0x82),
ILI9881C_COMMAND_INSTR(0x4A, 0x82),
ILI9881C_COMMAND_INSTR(0x4B, 0x82),
ILI9881C_COMMAND_INSTR(0x4C, 0x82),
ILI9881C_COMMAND_INSTR(0x4D, 0x82),
ILI9881C_COMMAND_INSTR(0x4E, 0x82),
ILI9881C_COMMAND_INSTR(0x4F, 0x82),
ILI9881C_COMMAND_INSTR(0x50, 0x82),
ILI9881C_COMMAND_INSTR(0x51, 0x82),
ILI9881C_COMMAND_INSTR(0x52, 0x82),
ILI9881C_COMMAND_INSTR(0x53, 0x82),
ILI9881C_COMMAND_INSTR(0x54, 0x82),
ILI9881C_COMMAND_INSTR(0x55, 0x82),
ILI9881C_COMMAND_INSTR(0x56, 0x82),
ILI9881C_COMMAND_INSTR(0x57, 0x82),
ILI9881C_COMMAND_INSTR(0x58, 0x82),
ILI9881C_COMMAND_INSTR(0x59, 0x82),
ILI9881C_COMMAND_INSTR(0x5A, 0x82),
ILI9881C_COMMAND_INSTR(0x5B, 0x82),
ILI9881C_COMMAND_INSTR(0x5C, 0x82),
ILI9881C_COMMAND_INSTR(0x5D, 0x82),
ILI9881C_COMMAND_INSTR(0x5E, 0x82),
ILI9881C_COMMAND_INSTR(0x5F, 0x82),
ILI9881C_COMMAND_INSTR(0x60, 0x82),
ILI9881C_COMMAND_INSTR(0x61, 0x82),
ILI9881C_COMMAND_INSTR(0x62, 0x82),
ILI9881C_COMMAND_INSTR(0x63, 0x82),
ILI9881C_COMMAND_INSTR(0x64, 0x82),
ILI9881C_COMMAND_INSTR(0x65, 0x82),
ILI9881C_COMMAND_INSTR(0x66, 0x82),
ILI9881C_COMMAND_INSTR(0x67, 0x82),
ILI9881C_COMMAND_INSTR(0x68, 0x82),
ILI9881C_COMMAND_INSTR(0x69, 0x82),
ILI9881C_COMMAND_INSTR(0x6A, 0x82),
ILI9881C_COMMAND_INSTR(0x6B, 0x83),
ILI9881C_COMMAND_INSTR(0x6C, 0x83),
ILI9881C_COMMAND_INSTR(0x6D, 0x83),
ILI9881C_COMMAND_INSTR(0x6E, 0x83),
ILI9881C_COMMAND_INSTR(0x6F, 0x83),
ILI9881C_COMMAND_INSTR(0x70, 0x83),
ILI9881C_COMMAND_INSTR(0x71, 0x83),
ILI9881C_COMMAND_INSTR(0x72, 0x83),
ILI9881C_COMMAND_INSTR(0x73, 0x83),
ILI9881C_COMMAND_INSTR(0x74, 0x83),
ILI9881C_COMMAND_INSTR(0x75, 0x83),
ILI9881C_COMMAND_INSTR(0x76, 0x83),
ILI9881C_COMMAND_INSTR(0x77, 0x83),
ILI9881C_COMMAND_INSTR(0x78, 0x83),
ILI9881C_COMMAND_INSTR(0x79, 0x83),
ILI9881C_COMMAND_INSTR(0x7A, 0x83),
ILI9881C_COMMAND_INSTR(0x7B, 0x83),
ILI9881C_COMMAND_INSTR(0x7C, 0x83),
ILI9881C_COMMAND_INSTR(0x7D, 0x83),
ILI9881C_COMMAND_INSTR(0x7E, 0x83),
ILI9881C_COMMAND_INSTR(0x7F, 0x83),
ILI9881C_SWITCH_PAGE_INSTR(6),
ILI9881C_COMMAND_INSTR(0x00, 0x83),
ILI9881C_COMMAND_INSTR(0x01, 0x83),
ILI9881C_COMMAND_INSTR(0x02, 0x83),
ILI9881C_COMMAND_INSTR(0x03, 0x83),
ILI9881C_COMMAND_INSTR(0x04, 0x83),
ILI9881C_COMMAND_INSTR(0x05, 0x83),
ILI9881C_COMMAND_INSTR(0x06, 0x83),
ILI9881C_COMMAND_INSTR(0x07, 0x83),
ILI9881C_COMMAND_INSTR(0x08, 0x83),
ILI9881C_COMMAND_INSTR(0x09, 0x83),
ILI9881C_COMMAND_INSTR(0x0A, 0x83),
ILI9881C_COMMAND_INSTR(0x0B, 0x83),
ILI9881C_COMMAND_INSTR(0x0C, 0x83),
ILI9881C_COMMAND_INSTR(0x0D, 0x83),
ILI9881C_COMMAND_INSTR(0x0E, 0x83),
ILI9881C_COMMAND_INSTR(0x0F, 0x83),
ILI9881C_COMMAND_INSTR(0x10, 0x83),
ILI9881C_COMMAND_INSTR(0x11, 0x83),
ILI9881C_COMMAND_INSTR(0x12, 0x83),
ILI9881C_COMMAND_INSTR(0x13, 0x83),
ILI9881C_COMMAND_INSTR(0x14, 0x83),
ILI9881C_COMMAND_INSTR(0x15, 0x83),
ILI9881C_COMMAND_INSTR(0x16, 0x84),
ILI9881C_COMMAND_INSTR(0x17, 0x84),
ILI9881C_COMMAND_INSTR(0x18, 0x84),
ILI9881C_COMMAND_INSTR(0x19, 0x84),
ILI9881C_COMMAND_INSTR(0x1A, 0x84),
ILI9881C_COMMAND_INSTR(0x1B, 0x84),
ILI9881C_COMMAND_INSTR(0x1C, 0x84),
ILI9881C_COMMAND_INSTR(0x1D, 0x84),
ILI9881C_COMMAND_INSTR(0x1E, 0x84),
ILI9881C_COMMAND_INSTR(0x1F, 0x84),
ILI9881C_COMMAND_INSTR(0x20, 0x84),
ILI9881C_COMMAND_INSTR(0x21, 0x84),
ILI9881C_COMMAND_INSTR(0x22, 0x84),
ILI9881C_COMMAND_INSTR(0x23, 0x84),
ILI9881C_COMMAND_INSTR(0x24, 0x84),
ILI9881C_COMMAND_INSTR(0x25, 0x84),
ILI9881C_COMMAND_INSTR(0x26, 0x84),
ILI9881C_COMMAND_INSTR(0x27, 0x84),
ILI9881C_COMMAND_INSTR(0x28, 0x84),
ILI9881C_COMMAND_INSTR(0x29, 0x84),
ILI9881C_COMMAND_INSTR(0x2A, 0x84),
ILI9881C_COMMAND_INSTR(0x2B, 0x84),
ILI9881C_COMMAND_INSTR(0x2C, 0x84),
ILI9881C_COMMAND_INSTR(0x2D, 0x84),
ILI9881C_COMMAND_INSTR(0x2E, 0x84),
ILI9881C_COMMAND_INSTR(0x2F, 0x84),
ILI9881C_COMMAND_INSTR(0x30, 0x84),
ILI9881C_COMMAND_INSTR(0x31, 0x84),
ILI9881C_COMMAND_INSTR(0x32, 0x84),
ILI9881C_COMMAND_INSTR(0x33, 0x84),
ILI9881C_COMMAND_INSTR(0x34, 0x84),
ILI9881C_COMMAND_INSTR(0x35, 0x84),
ILI9881C_COMMAND_INSTR(0x36, 0x84),
ILI9881C_COMMAND_INSTR(0x37, 0x84),
ILI9881C_COMMAND_INSTR(0x38, 0x84),
ILI9881C_COMMAND_INSTR(0x39, 0x84),
ILI9881C_COMMAND_INSTR(0x3A, 0x84),
ILI9881C_COMMAND_INSTR(0x3B, 0x84),
ILI9881C_COMMAND_INSTR(0x3C, 0x84),
ILI9881C_COMMAND_INSTR(0x3D, 0x84),
ILI9881C_COMMAND_INSTR(0x3E, 0x84),
ILI9881C_COMMAND_INSTR(0x3F, 0x84),
ILI9881C_COMMAND_INSTR(0x40, 0x84),
ILI9881C_COMMAND_INSTR(0x41, 0x85),
ILI9881C_COMMAND_INSTR(0x42, 0x85),
ILI9881C_COMMAND_INSTR(0x43, 0x85),
ILI9881C_COMMAND_INSTR(0x44, 0x85),
ILI9881C_COMMAND_INSTR(0x45, 0x85),
ILI9881C_COMMAND_INSTR(0x46, 0x85),
ILI9881C_COMMAND_INSTR(0x47, 0x85),
ILI9881C_COMMAND_INSTR(0x48, 0x85),
ILI9881C_COMMAND_INSTR(0x49, 0x85),
ILI9881C_COMMAND_INSTR(0x4A, 0x85),
ILI9881C_COMMAND_INSTR(0x4B, 0x85),
ILI9881C_COMMAND_INSTR(0x4C, 0x85),
ILI9881C_COMMAND_INSTR(0x4D, 0x85),
ILI9881C_COMMAND_INSTR(0x4E, 0x85),
ILI9881C_COMMAND_INSTR(0x4F, 0x85),
ILI9881C_COMMAND_INSTR(0x50, 0x85),
ILI9881C_COMMAND_INSTR(0x51, 0x85),
ILI9881C_COMMAND_INSTR(0x52, 0x85),
ILI9881C_COMMAND_INSTR(0x53, 0x85),
ILI9881C_COMMAND_INSTR(0x54, 0x85),
ILI9881C_COMMAND_INSTR(0x55, 0x85),
ILI9881C_COMMAND_INSTR(0x56, 0x85),
ILI9881C_COMMAND_INSTR(0x57, 0x85),
ILI9881C_COMMAND_INSTR(0x58, 0x85),
ILI9881C_COMMAND_INSTR(0x59, 0x85),
ILI9881C_COMMAND_INSTR(0x5A, 0x85),
ILI9881C_COMMAND_INSTR(0x5B, 0x85),
ILI9881C_COMMAND_INSTR(0x5C, 0x85),
ILI9881C_COMMAND_INSTR(0x5D, 0x85),
ILI9881C_COMMAND_INSTR(0x5E, 0x85),
ILI9881C_COMMAND_INSTR(0x5F, 0x85),
ILI9881C_COMMAND_INSTR(0x60, 0x85),
ILI9881C_COMMAND_INSTR(0x61, 0x85),
ILI9881C_COMMAND_INSTR(0x62, 0x85),
ILI9881C_COMMAND_INSTR(0x63, 0x85),
ILI9881C_COMMAND_INSTR(0x64, 0x85),
ILI9881C_COMMAND_INSTR(0x65, 0x85),
ILI9881C_COMMAND_INSTR(0x66, 0x85),
ILI9881C_COMMAND_INSTR(0x67, 0x85),
ILI9881C_COMMAND_INSTR(0x68, 0x85),
ILI9881C_COMMAND_INSTR(0x69, 0x85),
ILI9881C_COMMAND_INSTR(0x6A, 0x85),
ILI9881C_COMMAND_INSTR(0x6B, 0x86),
ILI9881C_COMMAND_INSTR(0x6C, 0x86),
ILI9881C_COMMAND_INSTR(0x6D, 0x86),
ILI9881C_COMMAND_INSTR(0x6E, 0x86),
ILI9881C_COMMAND_INSTR(0x6F, 0x86),
ILI9881C_COMMAND_INSTR(0x70, 0x86),
ILI9881C_COMMAND_INSTR(0x71, 0x86),
ILI9881C_COMMAND_INSTR(0x72, 0x86),
ILI9881C_COMMAND_INSTR(0x73, 0x86),
ILI9881C_COMMAND_INSTR(0x74, 0x86),
ILI9881C_COMMAND_INSTR(0x75, 0x86),
ILI9881C_COMMAND_INSTR(0x76, 0x86),
ILI9881C_COMMAND_INSTR(0x77, 0x86),
ILI9881C_COMMAND_INSTR(0x78, 0x86),
ILI9881C_COMMAND_INSTR(0x79, 0x86),
ILI9881C_COMMAND_INSTR(0x7A, 0x86),
ILI9881C_COMMAND_INSTR(0x7B, 0x86),
ILI9881C_COMMAND_INSTR(0x7C, 0x86),
ILI9881C_COMMAND_INSTR(0x7D, 0x86),
ILI9881C_COMMAND_INSTR(0x7E, 0x86),
ILI9881C_COMMAND_INSTR(0x7F, 0x86),
ILI9881C_SWITCH_PAGE_INSTR(7),
ILI9881C_COMMAND_INSTR(0x00, 0x00),
ILI9881C_COMMAND_INSTR(0x01, 0x00),
ILI9881C_COMMAND_INSTR(0x02, 0x00),
ILI9881C_COMMAND_INSTR(0x03, 0x00),
ILI9881C_COMMAND_INSTR(0x04, 0x00),
ILI9881C_COMMAND_INSTR(0x05, 0x00),
ILI9881C_COMMAND_INSTR(0x06, 0x00),
ILI9881C_COMMAND_INSTR(0x07, 0x00),
ILI9881C_COMMAND_INSTR(0x08, 0x00),
ILI9881C_COMMAND_INSTR(0x09, 0x00),
ILI9881C_COMMAND_INSTR(0x0A, 0x00),
ILI9881C_COMMAND_INSTR(0x0B, 0x00),
ILI9881C_COMMAND_INSTR(0x0C, 0x00),
ILI9881C_COMMAND_INSTR(0x0D, 0x00),
ILI9881C_COMMAND_INSTR(0x0E, 0x00),
ILI9881C_COMMAND_INSTR(0x0F, 0x00),
ILI9881C_COMMAND_INSTR(0x10, 0x00),
ILI9881C_COMMAND_INSTR(0x11, 0x00),
ILI9881C_COMMAND_INSTR(0x12, 0x00),
ILI9881C_COMMAND_INSTR(0x13, 0x00),
ILI9881C_COMMAND_INSTR(0x14, 0x00),
ILI9881C_COMMAND_INSTR(0x15, 0x00),
ILI9881C_COMMAND_INSTR(0x16, 0x00),
ILI9881C_COMMAND_INSTR(0x17, 0x00),
ILI9881C_COMMAND_INSTR(0x18, 0x00),
ILI9881C_COMMAND_INSTR(0x19, 0x00),
ILI9881C_COMMAND_INSTR(0x1A, 0x81),
ILI9881C_COMMAND_INSTR(0x1B, 0x81),
ILI9881C_COMMAND_INSTR(0x1C, 0x81),
ILI9881C_COMMAND_INSTR(0x1D, 0x81),
ILI9881C_COMMAND_INSTR(0x1E, 0x81),
ILI9881C_COMMAND_INSTR(0x1F, 0x81),
ILI9881C_COMMAND_INSTR(0x20, 0x81),
ILI9881C_COMMAND_INSTR(0x21, 0x81),
ILI9881C_COMMAND_INSTR(0x22, 0x81),
ILI9881C_COMMAND_INSTR(0x23, 0x81),
ILI9881C_COMMAND_INSTR(0x24, 0x81),
ILI9881C_COMMAND_INSTR(0x25, 0x81),
ILI9881C_COMMAND_INSTR(0x26, 0x81),
ILI9881C_COMMAND_INSTR(0x27, 0x81),
ILI9881C_COMMAND_INSTR(0x28, 0x81),
ILI9881C_COMMAND_INSTR(0x29, 0x81),
ILI9881C_COMMAND_INSTR(0x2A, 0x81),
ILI9881C_COMMAND_INSTR(0x2B, 0x81),
ILI9881C_COMMAND_INSTR(0x2C, 0x81),
ILI9881C_COMMAND_INSTR(0x2D, 0x81),
ILI9881C_COMMAND_INSTR(0x2E, 0x81),
ILI9881C_COMMAND_INSTR(0x2F, 0x81),
ILI9881C_COMMAND_INSTR(0x30, 0x81),
ILI9881C_COMMAND_INSTR(0x31, 0x81),
ILI9881C_COMMAND_INSTR(0x32, 0x81),
ILI9881C_COMMAND_INSTR(0x33, 0x81),
ILI9881C_COMMAND_INSTR(0x34, 0x81),
ILI9881C_COMMAND_INSTR(0x35, 0x81),
ILI9881C_COMMAND_INSTR(0x36, 0x81),
ILI9881C_COMMAND_INSTR(0x37, 0x81),
ILI9881C_COMMAND_INSTR(0x38, 0x81),
ILI9881C_COMMAND_INSTR(0x39, 0x81),
ILI9881C_COMMAND_INSTR(0x3A, 0x81),
ILI9881C_COMMAND_INSTR(0x3B, 0x81),
ILI9881C_COMMAND_INSTR(0x3C, 0x81),
ILI9881C_COMMAND_INSTR(0x3D, 0x81),
ILI9881C_COMMAND_INSTR(0x3E, 0x81),
ILI9881C_COMMAND_INSTR(0x3F, 0x81),
ILI9881C_COMMAND_INSTR(0x40, 0x81),
ILI9881C_COMMAND_INSTR(0x41, 0x81),
ILI9881C_COMMAND_INSTR(0x42, 0x81),
ILI9881C_COMMAND_INSTR(0x43, 0x81),
ILI9881C_COMMAND_INSTR(0x44, 0x81),
ILI9881C_COMMAND_INSTR(0x45, 0x81),
ILI9881C_COMMAND_INSTR(0x46, 0x81),
ILI9881C_COMMAND_INSTR(0x47, 0x81),
ILI9881C_COMMAND_INSTR(0x48, 0x81),
ILI9881C_COMMAND_INSTR(0x49, 0x81),
ILI9881C_COMMAND_INSTR(0x4A, 0x81),
ILI9881C_COMMAND_INSTR(0x4B, 0x81),
ILI9881C_COMMAND_INSTR(0x4C, 0x81),
ILI9881C_COMMAND_INSTR(0x4D, 0x82),
ILI9881C_COMMAND_INSTR(0x4E, 0x82),
ILI9881C_COMMAND_INSTR(0x4F, 0x82),
ILI9881C_COMMAND_INSTR(0x50, 0x82),
ILI9881C_COMMAND_INSTR(0x51, 0x82),
ILI9881C_COMMAND_INSTR(0x52, 0x82),
ILI9881C_COMMAND_INSTR(0x53, 0x82),
ILI9881C_COMMAND_INSTR(0x54, 0x82),
ILI9881C_COMMAND_INSTR(0x55, 0x82),
ILI9881C_COMMAND_INSTR(0x56, 0x82),
ILI9881C_COMMAND_INSTR(0x57, 0x82),
ILI9881C_COMMAND_INSTR(0x58, 0x82),
ILI9881C_COMMAND_INSTR(0x59, 0x82),
ILI9881C_COMMAND_INSTR(0x5A, 0x82),
ILI9881C_COMMAND_INSTR(0x5B, 0x82),
ILI9881C_COMMAND_INSTR(0x5C, 0x82),
ILI9881C_COMMAND_INSTR(0x5D, 0x82),
ILI9881C_COMMAND_INSTR(0x5E, 0x82),
ILI9881C_COMMAND_INSTR(0x5F, 0x82),
ILI9881C_COMMAND_INSTR(0x60, 0x82),
ILI9881C_COMMAND_INSTR(0x61, 0x82),
ILI9881C_COMMAND_INSTR(0x62, 0x82),
ILI9881C_COMMAND_INSTR(0x63, 0x82),
ILI9881C_COMMAND_INSTR(0x64, 0x82),
ILI9881C_COMMAND_INSTR(0x65, 0x82),
ILI9881C_COMMAND_INSTR(0x66, 0x82),
ILI9881C_COMMAND_INSTR(0x67, 0x82),
ILI9881C_COMMAND_INSTR(0x68, 0x82),
ILI9881C_COMMAND_INSTR(0x69, 0x82),
ILI9881C_COMMAND_INSTR(0x6A, 0x82),
ILI9881C_COMMAND_INSTR(0x6B, 0x82),
ILI9881C_COMMAND_INSTR(0x6C, 0x82),
ILI9881C_COMMAND_INSTR(0x6D, 0x82),
ILI9881C_COMMAND_INSTR(0x6E, 0x82),
ILI9881C_COMMAND_INSTR(0x6F, 0x82),
ILI9881C_COMMAND_INSTR(0x70, 0x82),
ILI9881C_COMMAND_INSTR(0x71, 0x82),
ILI9881C_COMMAND_INSTR(0x72, 0x82),
ILI9881C_COMMAND_INSTR(0x73, 0x82),
ILI9881C_COMMAND_INSTR(0x74, 0x82),
ILI9881C_COMMAND_INSTR(0x75, 0x82),
ILI9881C_COMMAND_INSTR(0x76, 0x82),
ILI9881C_COMMAND_INSTR(0x77, 0x82),
ILI9881C_COMMAND_INSTR(0x78, 0x82),
ILI9881C_COMMAND_INSTR(0x79, 0x82),
ILI9881C_COMMAND_INSTR(0x7A, 0x82),
ILI9881C_COMMAND_INSTR(0x7B, 0x82),
ILI9881C_COMMAND_INSTR(0x7C, 0x82),
ILI9881C_COMMAND_INSTR(0x7D, 0x82),
ILI9881C_COMMAND_INSTR(0x7E, 0x82),
ILI9881C_COMMAND_INSTR(0x7F, 0x82),
ILI9881C_SWITCH_PAGE_INSTR(8),
ILI9881C_COMMAND_INSTR(0x00, 0x82),
ILI9881C_COMMAND_INSTR(0x01, 0x83),
ILI9881C_COMMAND_INSTR(0x02, 0x83),
ILI9881C_COMMAND_INSTR(0x03, 0x83),
ILI9881C_COMMAND_INSTR(0x04, 0x83),
ILI9881C_COMMAND_INSTR(0x05, 0x83),
ILI9881C_COMMAND_INSTR(0x06, 0x83),
ILI9881C_COMMAND_INSTR(0x07, 0x83),
ILI9881C_COMMAND_INSTR(0x08, 0x83),
ILI9881C_COMMAND_INSTR(0x09, 0x83),
ILI9881C_COMMAND_INSTR(0x0A, 0x83),
ILI9881C_COMMAND_INSTR(0x0B, 0x83),
ILI9881C_COMMAND_INSTR(0x0C, 0x83),
ILI9881C_COMMAND_INSTR(0x0D, 0x83),
ILI9881C_COMMAND_INSTR(0x0E, 0x83),
ILI9881C_COMMAND_INSTR(0x0F, 0x83),
ILI9881C_COMMAND_INSTR(0x10, 0x83),
ILI9881C_COMMAND_INSTR(0x11, 0x83),
ILI9881C_COMMAND_INSTR(0x12, 0x83),
ILI9881C_COMMAND_INSTR(0x13, 0x83),
ILI9881C_COMMAND_INSTR(0x14, 0x83),
ILI9881C_COMMAND_INSTR(0x15, 0x83),
ILI9881C_COMMAND_INSTR(0x16, 0x83),
ILI9881C_COMMAND_INSTR(0x17, 0x83),
ILI9881C_COMMAND_INSTR(0x18, 0x83),
ILI9881C_COMMAND_INSTR(0x19, 0x83),
ILI9881C_COMMAND_INSTR(0x1A, 0x83),
ILI9881C_COMMAND_INSTR(0x1B, 0x83),
ILI9881C_COMMAND_INSTR(0x1C, 0x83),
ILI9881C_COMMAND_INSTR(0x1D, 0x83),
ILI9881C_COMMAND_INSTR(0x1E, 0x83),
ILI9881C_COMMAND_INSTR(0x1F, 0x83),
ILI9881C_COMMAND_INSTR(0x20, 0x83),
ILI9881C_COMMAND_INSTR(0x21, 0x83),
ILI9881C_COMMAND_INSTR(0x22, 0x83),
ILI9881C_COMMAND_INSTR(0x23, 0x83),
ILI9881C_COMMAND_INSTR(0x24, 0x83),
ILI9881C_COMMAND_INSTR(0x25, 0x83),
ILI9881C_COMMAND_INSTR(0x26, 0x83),
ILI9881C_COMMAND_INSTR(0x27, 0x83),
ILI9881C_COMMAND_INSTR(0x28, 0x83),
ILI9881C_COMMAND_INSTR(0x29, 0x83),
ILI9881C_COMMAND_INSTR(0x2A, 0x83),
ILI9881C_COMMAND_INSTR(0x2B, 0x83),
ILI9881C_COMMAND_INSTR(0x2C, 0x83),
ILI9881C_COMMAND_INSTR(0x2D, 0x83),
ILI9881C_COMMAND_INSTR(0x2E, 0x83),
ILI9881C_COMMAND_INSTR(0x2F, 0x83),
ILI9881C_COMMAND_INSTR(0x30, 0x83),
ILI9881C_COMMAND_INSTR(0x31, 0x83),
ILI9881C_COMMAND_INSTR(0x32, 0x83),
ILI9881C_COMMAND_INSTR(0x33, 0x83),
ILI9881C_COMMAND_INSTR(0x34, 0x84),
ILI9881C_COMMAND_INSTR(0x35, 0x84),
ILI9881C_COMMAND_INSTR(0x36, 0x84),
ILI9881C_COMMAND_INSTR(0x37, 0x84),
ILI9881C_COMMAND_INSTR(0x38, 0x84),
ILI9881C_COMMAND_INSTR(0x39, 0x84),
ILI9881C_COMMAND_INSTR(0x3A, 0x84),
ILI9881C_COMMAND_INSTR(0x3B, 0x84),
ILI9881C_COMMAND_INSTR(0x3C, 0x84),
ILI9881C_COMMAND_INSTR(0x3D, 0x84),
ILI9881C_COMMAND_INSTR(0x3E, 0x84),
ILI9881C_COMMAND_INSTR(0x3F, 0x84),
ILI9881C_COMMAND_INSTR(0x40, 0x84),
ILI9881C_COMMAND_INSTR(0x41, 0x84),
ILI9881C_COMMAND_INSTR(0x42, 0x84),
ILI9881C_COMMAND_INSTR(0x43, 0x84),
ILI9881C_COMMAND_INSTR(0x44, 0x84),
ILI9881C_COMMAND_INSTR(0x45, 0x84),
ILI9881C_COMMAND_INSTR(0x46, 0x84),
ILI9881C_COMMAND_INSTR(0x47, 0x84),
ILI9881C_COMMAND_INSTR(0x48, 0x84),
ILI9881C_COMMAND_INSTR(0x49, 0x84),
ILI9881C_COMMAND_INSTR(0x4A, 0x84),
ILI9881C_COMMAND_INSTR(0x4B, 0x84),
ILI9881C_COMMAND_INSTR(0x4C, 0x84),
ILI9881C_COMMAND_INSTR(0x4D, 0x84),
ILI9881C_COMMAND_INSTR(0x4E, 0x84),
ILI9881C_COMMAND_INSTR(0x4F, 0x84),
ILI9881C_COMMAND_INSTR(0x50, 0x84),
ILI9881C_COMMAND_INSTR(0x51, 0x84),
ILI9881C_COMMAND_INSTR(0x52, 0x84),
ILI9881C_COMMAND_INSTR(0x53, 0x84),
ILI9881C_COMMAND_INSTR(0x54, 0x84),
ILI9881C_COMMAND_INSTR(0x55, 0x84),
ILI9881C_COMMAND_INSTR(0x56, 0x84),
ILI9881C_COMMAND_INSTR(0x57, 0x84),
ILI9881C_COMMAND_INSTR(0x58, 0x84),
ILI9881C_COMMAND_INSTR(0x59, 0x84),
ILI9881C_COMMAND_INSTR(0x5A, 0x84),
ILI9881C_COMMAND_INSTR(0x5B, 0x84),
ILI9881C_COMMAND_INSTR(0x5C, 0x84),
ILI9881C_COMMAND_INSTR(0x5D, 0x84),
ILI9881C_COMMAND_INSTR(0x5E, 0x84),
ILI9881C_COMMAND_INSTR(0x5F, 0x84),
ILI9881C_COMMAND_INSTR(0x60, 0x84),
ILI9881C_COMMAND_INSTR(0x61, 0x84),
ILI9881C_COMMAND_INSTR(0x62, 0x84),
ILI9881C_COMMAND_INSTR(0x63, 0x84),
ILI9881C_COMMAND_INSTR(0x64, 0x84),
ILI9881C_COMMAND_INSTR(0x65, 0x84),
ILI9881C_COMMAND_INSTR(0x66, 0x84),
ILI9881C_COMMAND_INSTR(0x67, 0x85),
ILI9881C_COMMAND_INSTR(0x68, 0x85),
ILI9881C_COMMAND_INSTR(0x69, 0x85),
ILI9881C_COMMAND_INSTR(0x6A, 0x85),
ILI9881C_COMMAND_INSTR(0x6B, 0x85),
ILI9881C_COMMAND_INSTR(0x6C, 0x85),
ILI9881C_COMMAND_INSTR(0x6D, 0x85),
ILI9881C_COMMAND_INSTR(0x6E, 0x85),
ILI9881C_COMMAND_INSTR(0x6F, 0x85),
ILI9881C_COMMAND_INSTR(0x70, 0x85),
ILI9881C_COMMAND_INSTR(0x71, 0x85),
ILI9881C_COMMAND_INSTR(0x72, 0x85),
ILI9881C_COMMAND_INSTR(0x73, 0x85),
ILI9881C_COMMAND_INSTR(0x74, 0x85),
ILI9881C_COMMAND_INSTR(0x75, 0x85),
ILI9881C_COMMAND_INSTR(0x76, 0x85),
ILI9881C_COMMAND_INSTR(0x77, 0x85),
ILI9881C_COMMAND_INSTR(0x78, 0x85),
ILI9881C_COMMAND_INSTR(0x79, 0x85),
ILI9881C_COMMAND_INSTR(0x7A, 0x85),
ILI9881C_COMMAND_INSTR(0x7B, 0x85),
ILI9881C_COMMAND_INSTR(0x7C, 0x85),
ILI9881C_COMMAND_INSTR(0x7D, 0x85),
ILI9881C_COMMAND_INSTR(0x7E, 0x85),
ILI9881C_COMMAND_INSTR(0x7F, 0x85),
ILI9881C_SWITCH_PAGE_INSTR(9),
ILI9881C_COMMAND_INSTR(0x00, 0x00),
ILI9881C_COMMAND_INSTR(0x01, 0x00),
ILI9881C_COMMAND_INSTR(0x02, 0x00),
ILI9881C_COMMAND_INSTR(0x03, 0x00),
ILI9881C_COMMAND_INSTR(0x04, 0x00),
ILI9881C_COMMAND_INSTR(0x05, 0x00),
ILI9881C_COMMAND_INSTR(0x06, 0x00),
ILI9881C_COMMAND_INSTR(0x07, 0x00),
ILI9881C_COMMAND_INSTR(0x08, 0x00),
ILI9881C_COMMAND_INSTR(0x09, 0x00),
ILI9881C_COMMAND_INSTR(0x0A, 0x00),
ILI9881C_COMMAND_INSTR(0x0B, 0x00),
ILI9881C_COMMAND_INSTR(0x0C, 0x00),
ILI9881C_COMMAND_INSTR(0x0D, 0x00),
ILI9881C_COMMAND_INSTR(0x0E, 0x00),
ILI9881C_COMMAND_INSTR(0x0F, 0x00),
ILI9881C_COMMAND_INSTR(0x10, 0x00),
ILI9881C_COMMAND_INSTR(0x11, 0x00),
ILI9881C_COMMAND_INSTR(0x12, 0x00),
ILI9881C_COMMAND_INSTR(0x13, 0x00),
ILI9881C_COMMAND_INSTR(0x14, 0x00),
ILI9881C_COMMAND_INSTR(0x15, 0x00),
ILI9881C_COMMAND_INSTR(0x16, 0x00),
ILI9881C_COMMAND_INSTR(0x17, 0x00),
ILI9881C_COMMAND_INSTR(0x18, 0x00),
ILI9881C_COMMAND_INSTR(0x19, 0x00),
ILI9881C_COMMAND_INSTR(0x1A, 0x00),
ILI9881C_COMMAND_INSTR(0x1B, 0x00),
ILI9881C_COMMAND_INSTR(0x1C, 0x00),
ILI9881C_COMMAND_INSTR(0x1D, 0x00),
ILI9881C_COMMAND_INSTR(0x1E, 0x00),
ILI9881C_COMMAND_INSTR(0x1F, 0x00),
ILI9881C_COMMAND_INSTR(0x20, 0x00),
ILI9881C_COMMAND_INSTR(0x21, 0x00),
ILI9881C_COMMAND_INSTR(0x22, 0x00),
ILI9881C_COMMAND_INSTR(0x23, 0x00),
ILI9881C_COMMAND_INSTR(0x24, 0x00),
ILI9881C_COMMAND_INSTR(0x25, 0x00),
ILI9881C_COMMAND_INSTR(0x26, 0x00),
ILI9881C_COMMAND_INSTR(0x27, 0x00),
ILI9881C_COMMAND_INSTR(0x28, 0x00),
ILI9881C_COMMAND_INSTR(0x29, 0x00),
ILI9881C_COMMAND_INSTR(0x2A, 0x00),
ILI9881C_COMMAND_INSTR(0x2B, 0x00),
ILI9881C_COMMAND_INSTR(0x2C, 0x00),
ILI9881C_COMMAND_INSTR(0x2D, 0x00),
ILI9881C_COMMAND_INSTR(0x2E, 0x00),
ILI9881C_COMMAND_INSTR(0x2F, 0x00),
ILI9881C_COMMAND_INSTR(0x30, 0x00),
ILI9881C_COMMAND_INSTR(0x31, 0x00),
ILI9881C_COMMAND_INSTR(0x32, 0x00),
ILI9881C_COMMAND_INSTR(0x33, 0x00),
ILI9881C_COMMAND_INSTR(0x34, 0x00),
ILI9881C_COMMAND_INSTR(0x35, 0x00),
ILI9881C_COMMAND_INSTR(0x36, 0x00),
ILI9881C_COMMAND_INSTR(0x37, 0x00),
ILI9881C_COMMAND_INSTR(0x38, 0x00),
ILI9881C_COMMAND_INSTR(0x39, 0x00),
ILI9881C_COMMAND_INSTR(0x3A, 0x00),
ILI9881C_COMMAND_INSTR(0x3B, 0x00),
ILI9881C_COMMAND_INSTR(0x3C, 0x00),
ILI9881C_COMMAND_INSTR(0x3D, 0x00),
ILI9881C_COMMAND_INSTR(0x3E, 0x00),
ILI9881C_COMMAND_INSTR(0x3F, 0x00),
ILI9881C_COMMAND_INSTR(0x40, 0x00),
ILI9881C_COMMAND_INSTR(0x41, 0x00),
ILI9881C_COMMAND_INSTR(0x42, 0x00),
ILI9881C_COMMAND_INSTR(0x43, 0x00),
ILI9881C_COMMAND_INSTR(0x44, 0x00),
ILI9881C_COMMAND_INSTR(0x45, 0x00),
ILI9881C_COMMAND_INSTR(0x46, 0x00),
ILI9881C_COMMAND_INSTR(0x47, 0x00),
ILI9881C_COMMAND_INSTR(0x48, 0x00),
ILI9881C_COMMAND_INSTR(0x49, 0x00),
ILI9881C_COMMAND_INSTR(0x4A, 0x00),
ILI9881C_COMMAND_INSTR(0x4B, 0x00),
ILI9881C_COMMAND_INSTR(0x4C, 0x00),
ILI9881C_COMMAND_INSTR(0x4D, 0x00),
ILI9881C_COMMAND_INSTR(0x4E, 0x00),
ILI9881C_COMMAND_INSTR(0x4F, 0x00),
ILI9881C_COMMAND_INSTR(0x50, 0x00),
ILI9881C_COMMAND_INSTR(0x51, 0x00),
ILI9881C_COMMAND_INSTR(0x52, 0x00),
ILI9881C_COMMAND_INSTR(0x53, 0x00),
ILI9881C_COMMAND_INSTR(0x54, 0x00),
ILI9881C_COMMAND_INSTR(0x55, 0x00),
ILI9881C_COMMAND_INSTR(0x56, 0x00),
ILI9881C_COMMAND_INSTR(0x57, 0x00),
ILI9881C_COMMAND_INSTR(0x58, 0x00),
ILI9881C_COMMAND_INSTR(0x59, 0x00),
ILI9881C_COMMAND_INSTR(0x5A, 0x00),
ILI9881C_COMMAND_INSTR(0x5B, 0x00),
ILI9881C_COMMAND_INSTR(0x5C, 0x00),
ILI9881C_COMMAND_INSTR(0x5D, 0x00),
ILI9881C_COMMAND_INSTR(0x5E, 0x00),
ILI9881C_COMMAND_INSTR(0x5F, 0x00),
ILI9881C_COMMAND_INSTR(0x60, 0x00),
ILI9881C_COMMAND_INSTR(0x61, 0x00),
ILI9881C_COMMAND_INSTR(0x62, 0x00),
ILI9881C_COMMAND_INSTR(0x63, 0x00),
ILI9881C_COMMAND_INSTR(0x64, 0x00),
ILI9881C_COMMAND_INSTR(0x65, 0x00),
ILI9881C_COMMAND_INSTR(0x66, 0x00),
ILI9881C_COMMAND_INSTR(0x67, 0x00),
ILI9881C_COMMAND_INSTR(0x68, 0x00),
ILI9881C_COMMAND_INSTR(0x69, 0x00),
ILI9881C_COMMAND_INSTR(0x6A, 0x00),
ILI9881C_COMMAND_INSTR(0x6B, 0x00),
ILI9881C_COMMAND_INSTR(0x6C, 0x00),
ILI9881C_COMMAND_INSTR(0x6D, 0x00),
ILI9881C_COMMAND_INSTR(0x6E, 0x00),
ILI9881C_COMMAND_INSTR(0x6F, 0x00),
ILI9881C_COMMAND_INSTR(0x70, 0x00),
ILI9881C_COMMAND_INSTR(0x71, 0x00),
ILI9881C_COMMAND_INSTR(0x72, 0x00),
ILI9881C_COMMAND_INSTR(0x73, 0x00),
ILI9881C_COMMAND_INSTR(0x74, 0x00),
ILI9881C_COMMAND_INSTR(0x75, 0x00),
ILI9881C_COMMAND_INSTR(0x76, 0x00),
ILI9881C_COMMAND_INSTR(0x77, 0x00),
ILI9881C_COMMAND_INSTR(0x78, 0x00),
ILI9881C_COMMAND_INSTR(0x79, 0x00),
ILI9881C_COMMAND_INSTR(0x7A, 0x00),
ILI9881C_COMMAND_INSTR(0x7B, 0x00),
ILI9881C_COMMAND_INSTR(0x7C, 0x00),
ILI9881C_COMMAND_INSTR(0x7D, 0x00),
ILI9881C_COMMAND_INSTR(0x7E, 0x00),
ILI9881C_COMMAND_INSTR(0x7F, 0x00),
ILI9881C_SWITCH_PAGE_INSTR(0x0A),
ILI9881C_COMMAND_INSTR(0x00, 0x00),
ILI9881C_COMMAND_INSTR(0x01, 0x00),
ILI9881C_COMMAND_INSTR(0x02, 0x00),
ILI9881C_COMMAND_INSTR(0x03, 0x00),
ILI9881C_COMMAND_INSTR(0x04, 0x00),
ILI9881C_COMMAND_INSTR(0x05, 0x00),
ILI9881C_COMMAND_INSTR(0x06, 0x00),
ILI9881C_COMMAND_INSTR(0x07, 0x00),
ILI9881C_COMMAND_INSTR(0x08, 0x00),
ILI9881C_COMMAND_INSTR(0x09, 0x00),
ILI9881C_COMMAND_INSTR(0x0A, 0x00),
ILI9881C_COMMAND_INSTR(0x0B, 0x00),
ILI9881C_COMMAND_INSTR(0x0C, 0x00),
ILI9881C_COMMAND_INSTR(0x0D, 0x00),
ILI9881C_COMMAND_INSTR(0x0E, 0x00),
ILI9881C_COMMAND_INSTR(0x0F, 0x00),
ILI9881C_COMMAND_INSTR(0x10, 0x00),
ILI9881C_COMMAND_INSTR(0x11, 0x00),
ILI9881C_COMMAND_INSTR(0x12, 0x00),
ILI9881C_COMMAND_INSTR(0x13, 0x00),
ILI9881C_COMMAND_INSTR(0x14, 0x00),
ILI9881C_COMMAND_INSTR(0x15, 0x00),
ILI9881C_COMMAND_INSTR(0x16, 0x00),
ILI9881C_COMMAND_INSTR(0x17, 0x00),
ILI9881C_COMMAND_INSTR(0x18, 0x00),
ILI9881C_COMMAND_INSTR(0x19, 0x00),
ILI9881C_COMMAND_INSTR(0x1A, 0x00),
ILI9881C_COMMAND_INSTR(0x1B, 0x00),
ILI9881C_COMMAND_INSTR(0x1C, 0x00),
ILI9881C_COMMAND_INSTR(0x1D, 0x00),
ILI9881C_COMMAND_INSTR(0x1E, 0x00),
ILI9881C_COMMAND_INSTR(0x1F, 0x00),
ILI9881C_COMMAND_INSTR(0x20, 0x00),
ILI9881C_COMMAND_INSTR(0x21, 0x00),
ILI9881C_COMMAND_INSTR(0x22, 0x00),
ILI9881C_COMMAND_INSTR(0x23, 0x00),
ILI9881C_COMMAND_INSTR(0x24, 0x00),
ILI9881C_COMMAND_INSTR(0x25, 0x00),
ILI9881C_COMMAND_INSTR(0x26, 0x00),
ILI9881C_COMMAND_INSTR(0x27, 0x00),
ILI9881C_COMMAND_INSTR(0x28, 0x00),
ILI9881C_COMMAND_INSTR(0x29, 0x00),
ILI9881C_COMMAND_INSTR(0x2A, 0x00),
ILI9881C_COMMAND_INSTR(0x2B, 0x00),
ILI9881C_COMMAND_INSTR(0x2C, 0x00),
ILI9881C_COMMAND_INSTR(0x2D, 0x00),
ILI9881C_COMMAND_INSTR(0x2E, 0x00),
ILI9881C_COMMAND_INSTR(0x2F, 0x00),
ILI9881C_COMMAND_INSTR(0x30, 0x00),
ILI9881C_COMMAND_INSTR(0x31, 0x00),
ILI9881C_COMMAND_INSTR(0x32, 0x00),
ILI9881C_COMMAND_INSTR(0x33, 0x00),
ILI9881C_COMMAND_INSTR(0x34, 0x00),
ILI9881C_COMMAND_INSTR(0x35, 0x00),
ILI9881C_COMMAND_INSTR(0x36, 0x00),
ILI9881C_COMMAND_INSTR(0x37, 0x00),
ILI9881C_COMMAND_INSTR(0x38, 0x00),
ILI9881C_COMMAND_INSTR(0x39, 0x00),
ILI9881C_COMMAND_INSTR(0x3A, 0x00),
ILI9881C_COMMAND_INSTR(0x3B, 0x00),
ILI9881C_COMMAND_INSTR(0x3C, 0x00),
ILI9881C_COMMAND_INSTR(0x3D, 0x00),
ILI9881C_COMMAND_INSTR(0x3E, 0x00),
ILI9881C_COMMAND_INSTR(0x3F, 0x00),
ILI9881C_COMMAND_INSTR(0x40, 0x00),
ILI9881C_COMMAND_INSTR(0x41, 0x00),
ILI9881C_COMMAND_INSTR(0x42, 0x00),
ILI9881C_COMMAND_INSTR(0x43, 0x00),
ILI9881C_COMMAND_INSTR(0x44, 0x00),
ILI9881C_COMMAND_INSTR(0x45, 0x00),
ILI9881C_COMMAND_INSTR(0x46, 0x00),
ILI9881C_COMMAND_INSTR(0x47, 0x00),
ILI9881C_COMMAND_INSTR(0x48, 0x00),
ILI9881C_COMMAND_INSTR(0x49, 0x00),
ILI9881C_COMMAND_INSTR(0x4A, 0x00),
ILI9881C_COMMAND_INSTR(0x4B, 0x00),
ILI9881C_COMMAND_INSTR(0x4C, 0x00),
ILI9881C_COMMAND_INSTR(0x4D, 0x00),
ILI9881C_COMMAND_INSTR(0x4E, 0x00),
ILI9881C_COMMAND_INSTR(0x4F, 0x00),
ILI9881C_COMMAND_INSTR(0x50, 0x00),
ILI9881C_COMMAND_INSTR(0x51, 0x00),
ILI9881C_COMMAND_INSTR(0x52, 0x00),
ILI9881C_COMMAND_INSTR(0x53, 0x00),
ILI9881C_COMMAND_INSTR(0x54, 0x00),
ILI9881C_COMMAND_INSTR(0x55, 0x00),
ILI9881C_COMMAND_INSTR(0x56, 0x00),
ILI9881C_COMMAND_INSTR(0x57, 0x00),
ILI9881C_COMMAND_INSTR(0x58, 0x00),
ILI9881C_COMMAND_INSTR(0x59, 0x00),
ILI9881C_COMMAND_INSTR(0x5A, 0x00),
ILI9881C_COMMAND_INSTR(0x5B, 0x00),
ILI9881C_COMMAND_INSTR(0x5C, 0x00),
ILI9881C_COMMAND_INSTR(0x5D, 0x00),
ILI9881C_COMMAND_INSTR(0x5E, 0x00),
ILI9881C_COMMAND_INSTR(0x5F, 0x00),
ILI9881C_COMMAND_INSTR(0x60, 0x00),
ILI9881C_COMMAND_INSTR(0x61, 0x00),
ILI9881C_COMMAND_INSTR(0x62, 0x00),
ILI9881C_COMMAND_INSTR(0x63, 0x00),
ILI9881C_COMMAND_INSTR(0x64, 0x00),
ILI9881C_COMMAND_INSTR(0x65, 0x00),
ILI9881C_COMMAND_INSTR(0x66, 0x00),
ILI9881C_COMMAND_INSTR(0x67, 0x00),
ILI9881C_COMMAND_INSTR(0x68, 0x00),
ILI9881C_COMMAND_INSTR(0x69, 0x00),
ILI9881C_COMMAND_INSTR(0x6A, 0x00),
ILI9881C_COMMAND_INSTR(0x6B, 0x00),
ILI9881C_COMMAND_INSTR(0x6C, 0x00),
ILI9881C_COMMAND_INSTR(0x6D, 0x00),
ILI9881C_COMMAND_INSTR(0x6E, 0x00),
ILI9881C_COMMAND_INSTR(0x6F, 0x00),
ILI9881C_COMMAND_INSTR(0x70, 0x00),
ILI9881C_COMMAND_INSTR(0x71, 0x00),
ILI9881C_COMMAND_INSTR(0x72, 0x00),
ILI9881C_COMMAND_INSTR(0x73, 0x00),
ILI9881C_COMMAND_INSTR(0x74, 0x00),
ILI9881C_COMMAND_INSTR(0x75, 0x00),
ILI9881C_COMMAND_INSTR(0x76, 0x00),
ILI9881C_COMMAND_INSTR(0x77, 0x00),
ILI9881C_COMMAND_INSTR(0x78, 0x00),
ILI9881C_COMMAND_INSTR(0x79, 0x00),
ILI9881C_COMMAND_INSTR(0x7A, 0x00),
ILI9881C_COMMAND_INSTR(0x7B, 0x00),
ILI9881C_COMMAND_INSTR(0x7C, 0x00),
ILI9881C_COMMAND_INSTR(0x7D, 0x00),
ILI9881C_COMMAND_INSTR(0x7E, 0x00),
ILI9881C_COMMAND_INSTR(0x7F, 0x00),
ILI9881C_SWITCH_PAGE_INSTR(0),
ILI9881C_COMMAND_INSTR(0x36, 0x03),
ILI9881C_COMMAND_INSTR(0x35, 0x00),
ILI9881C_SWITCH_PAGE_INSTR(2),
ILI9881C_COMMAND_INSTR(0x06, 0x30),
ILI9881C_COMMAND_INSTR(0x07, 0x01),
};

static int ili9881c_switch_page(u32 sel, u8 page)
{
#if defined(SUPPORT_DSI)
	u8 buf[3] = { 0x98, 0x81, page };
	int ret;

	ret = dsi_dcs_wr(sel, 0xff, buf, 3);
	if (ret < 0)
		return ret;
#endif
	return 0;
}

static int ili9881c_send_cmd_data(u32 sel, u8 cmd, u8 data)
{
#if defined(SUPPORT_DSI)
	u8 buf[1] = { data };
	int ret;

	ret = dsi_dcs_wr(sel, cmd, buf, 1);
	if (ret < 0)
		return ret;
#endif
	return 0;
}

/*add panel initialization code*/
static struct LCM_setting_table LCM_ILI9881C_setting[] = {
	/*sleep exit*/
	{0x11, 0, {0x00 } },
	{REGFLAG_DELAY, REGFLAG_DELAY, {120} },
	/*display on*/
	{0x29, 0, {0x00 } },
	{REGFLAG_DELAY, REGFLAG_DELAY, {10} },
	{REGFLAG_END_OF_TABLE, REGFLAG_END_OF_TABLE, {} }
};

static void LCD_panel_init(u32 sel)
{
	__u32 i;

	int ret;
	char model_name[25];

	disp_sys_script_get_item("lcd0", "lcd_model_name",
		(int *)model_name, 25);
	sunxi_lcd_dsi_clk_enable(sel);
	sunxi_lcd_delay_ms(20);

	for (i = 0; i < ARRAY_SIZE(ili9881c_init); i++) {
		struct ili9881c_instr *instr = &ili9881c_init[i];

		if (instr->op == ILI9881C_SWITCH_PAGE)
			ret = ili9881c_switch_page(sel, instr->arg.page);
		else if (instr->op == ILI9881C_COMMAND)
			ret = ili9881c_send_cmd_data(sel, instr->arg.cmd.cmd,
					instr->arg.cmd.data);

		if (ret)
			return ;
	}

	ret = ili9881c_switch_page(sel, 0);
	if (ret)
		return ;

	for (i = 0;; i++) {
		if (LCM_ILI9881C_setting[i].count == REGFLAG_END_OF_TABLE)
			break;
		else if (LCM_ILI9881C_setting[i].count == REGFLAG_DELAY)
			sunxi_lcd_delay_ms(
			LCM_ILI9881C_setting[i].para_list[0]);
#if defined(SUPPORT_DSI)
		else
			dsi_dcs_wr(sel, LCM_ILI9881C_setting[i].cmd,
				LCM_ILI9881C_setting[i].para_list,
				LCM_ILI9881C_setting[i].count);
#endif
	}
}

static void LCD_panel_exit(u32 sel)
{
	sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_SET_DISPLAY_OFF);
	sunxi_lcd_delay_ms(20);
	sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_ENTER_SLEEP_MODE);
	sunxi_lcd_delay_ms(80);
}

/* sel: 0:lcd0; 1:lcd1 */
static s32 LCD_user_defined_func(u32 sel, u32 para1, u32 para2, u32 para3)
{
	return 0;
}

/* sel: 0:lcd0; 1:lcd1 */
/*static s32 LCD_set_bright(u32 sel, u32 bright)*/
/*{*/
	/*sunxi_lcd_dsi_dcs_write_1para(sel,0x51,bright);*/
	/*return 0;*/
/*}*/

struct __lcd_panel ili9881c_dsi_panel = {
	/* panel driver name, must mach the name of
	 * lcd_drv_name in sys_config.fex
	*/
	.name = "ili9881c_dsi_panel",
	.func = {
	.cfg_panel_info = LCD_cfg_panel_info,
	.cfg_open_flow = LCD_open_flow,
	.cfg_close_flow = LCD_close_flow,
	.lcd_user_defined_func = LCD_user_defined_func,
	/*.set_bright = LCD_set_bright, */
	},
};
